from django.http.response import HttpResponse
from django.shortcuts import render
import logging 
from django.core.servers.basehttp import WSGIRequestHandler
from logging.handlers import RotatingFileHandler
# Create your views here.
from logging import LogRecord
def logger_test(request):
    logger = logging.getLogger('custom')
    logger.debug('日志 debug  级别')
    logger.info('日info  级别')
    # for i in range(10):
    logger.warning('日志 warning  级别')
    logger.error('日志测试 error  级别')
    logger.critical('日志 测试critical  级别')

    #测试默认的DEFAULT_LOGGING
    logger_server = logging.getLogger('django.server')
    logger_server.debug('logger_server debug 测试')
    logger_server.info('logger_server info 测试-------------------')
    logger_server.warning('logger_server warning 测试')
    logger_server.error('logger_server error 测试')

    return HttpResponse('学习Django框架中日志')

def logger_propagate_test(request):
    logger = logging.getLogger('logger_study.file')
    logger.debug('日志测试 debug  级别  propagate')
    logger.info('日志测试 info  级别 propagate')
    logger.warning('日志测试 warning  级别 propagate')
    logger.error('日志测试 error  级别 propagate')
    logger.critical('日志测试 critical  级别 propagate')

    return HttpResponse('学习Django框架中日志propagate')
